package com.zhang.chatcenter.controller.chat;

import com.zhang.chatcenter.common.model.dao.RoomDO;
import com.zhang.chatcenter.common.model.dto.RoomMessageDTO;
import com.zhang.chatcenter.manager.IChatManager;
import com.zhang.infrastructure.model.KingHoodResponseVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * description
 *
 * @author zhangFanJun
 * @date 2024-03-17 10:32
 **/
@RequiredArgsConstructor
@Slf4j
@RequestMapping("/chatInfo")
@RestController
public class ChatController {

    private final IChatManager chatManager;

    /**
     * 我的聊天列表
     *
     * @param groupChat 是否群聊
     * @return 聊天列表
     * @author zfj
     * @date 2024/03/19
     */
    @GetMapping("/getMyChat")
    public KingHoodResponseVO<List<RoomDO>> getMyChat(Boolean groupChat) {

        return KingHoodResponseVO.success(chatManager.getMyChat(groupChat));
    }


    /**
     * 聊天内容
     *
     * @param roomId 房间id
     * @return 聊天内容
     * @author zfj
     * @date 2024/03/19
     */
    @GetMapping("/roomContent/{roomId}")
    public KingHoodResponseVO<List<RoomMessageDTO>> getRoomContent(@PathVariable("roomId") Long roomId) {

        return KingHoodResponseVO.success(chatManager.getRoomContent(roomId));
    }

}
